<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="dao.UserDAO"%>
<%@page import="model.User"%>
<%@page import="java.sql.Date"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="javax.xml.transform.Result"%>
<%@page import="form.ConnectionDB"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<jsp:include page="Admin_includes/header.jsp"></jsp:include>
<style type="text/css">
.xoa {
	text-indent: -99999px;
	width: 28px;
	height: 23px;
	background: url("Admin_images/xoa.png") no-repeat center;
	border: none;
}

.sua {
	text-indent:-99999px;
	width:28px;
	height:23px;
	background:url("Admin_images/sua.png");
	border: none;
}
</style>
<div id="center-content">
	<div id="left">
		<jsp:include page="Admin_includes/left.jsp"></jsp:include>
	</div>
	<!-- end left -->







	<div id="right">
		<table class="table1" width="740">

			<tr>
				<th>Email</th>
				<th>Tên</th>
				<th>Cấp độ</th>
				<th>Giới tính</th>
				<th>Sinh nhật</th>
				<th>Sửa</th>
				<th>Xóa</th>
			</tr>
			<%
				String sql = "select * from users";
				String err="";
				ResultSet rs = null;
				String sGioitinh,sDate;
				String email = (String) request.getAttribute("email");
				try {
					rs = ConnectionDB.getConnection().createStatement()
							.executeQuery(sql);
			%>
			<%
				while (rs.next()) {
						email = rs.getString("email");
						String ten = rs.getString("ten") + " " + rs.getString("ho");						
						int capdo = rs.getInt("capdo");
						int gioitinh = rs.getInt("gioitinh");
						if (gioitinh == 1) {
							sGioitinh = "Nam";
						} else if (gioitinh == 2) {
							sGioitinh = "Nữ";
						}else if(gioitinh ==3){
							sGioitinh ="Chưa xác định";
						} else {
							sGioitinh = "";
						}

						Date date = rs.getDate("sinhnhat");
						
						
			%>
			<tr>
				<td><%=email%></td>
				<td><%=ten%></td>
				
				<td><%=capdo%></td>
				<td><%=sGioitinh%></td>
				<td><%=date%></td>
				<td class="suaxoa"><form action="Admin_suathanhvien.jsp" method="post"><input 
						type="submit" value="<%=email%>" name="email" class="sua"  title="Sửa"/></form>
				</td>


				<td class="suaxoa"><form action="xoathanhvien" method="post">

						<input type="submit" onclick="return confirmAction()"
							value="<%=email%>" name="email" class="xoa" title="Xóa"/>

					</form></td>

			</tr>

			<%
				}
			%>

			<%
				} catch (Exception e) {
					err="Hệ thống chưa kết nối cơ sở dữ liệu!Chúng tôi sẽ nhanh chóng khắc phục!";
				}
			%>



		</table>
		<script>
			function confirmAction() {
				return confirm("Bạc có chắc chắn muốn xóa!!");

			}
		</script>
	</div>
	<label style="color:#EE2C2C; font-size: 18px; font-weight: bold;"><%=err%></label>
	<!-- end right -->




</div>
<!-- end center-content-->
<jsp:include page="Admin_includes/footer.jsp"></jsp:include>